/**
* @Title: insuredBlacklist_ctrl.js
* @Description: TODO
* Copyright: Copyright (c) 2014 
 * Company:中国平安
*
* @Project HIMS-FWA
* @author EX-XIEYUWEN001
* @date 2014年10月29日 下午14:46:06
* @version V1.0
*/
;
(function(){
	'use strict';
	
	var app = angular.module('fwa.mainApp');
	app.controller('InsuredBlackCheckProcessCtrl', ['$scope','$state', '$http','$stateParams','BaseURL', 'Modal','$modal','IntegrityMedicalService','CommunityService','BaseService','$modalInstance',
	                                             function($scope,$state, $http,$stateParams, baseUrl, Modal,$modal,IntegrityMedicalService,CommunityService,BaseService,$modalInstance){
		
		$scope.auditOpinionList=[{code:'1',label:'同意'},{code:'0',label:'不同意'}];
	
		
		$scope.auditObj={};
		
		initCheckProcessData();
		
	
		/**
		 * 根据id加载对应的参保人黑名单
		 */
       function initCheckProcessData(){
    	   $http({
				method : 'post',
				cache : false,
				url : baseUrl + 'integrityBlackAudit/initAuditInfo.do',
				params :{
					id:$scope.blackId
				}
			}).success(function(response, status, headers, config) {
				$scope.person=response;
			});
       }
       
       /**
        * 审核提交
        */
       $scope.onSubmit=function(){
    	   if($scope.auditObj.opinion){
    		   if($scope.auditObj.opinion=='0'){
    			   if(!$scope.auditObj.opinionDesc){
    				   Modal.alert('意见说明不能为空!');
    				   return;
    			   }
    		   }
    		  var codes=new Array();
    		  codes.push($scope.blackId);
    		  $http({
   				method : 'post',
   				cache : false,
   				url : baseUrl + 'integrityBlackAudit/checkAuditBlackInfo.do',
   				params :{
   					codes:codes,
   					opinion:$scope.auditObj.opinion,
   				    opinionDesc:$scope.auditObj.opinionDesc
   				}
   			}).success(function(response, status, headers, config) {
   				if(response.flag){
   					Modal.alert(response.msg);
   					$scope.commonQuery();
   					$scope.onClose();
   				}else{
   					$scope.onClose();
   					Modal.alert(response.msg);
   				}
   			});  
    		   
    		   
    		   
    	   }else{
    		   Modal.alert('审核意见不能为空!');
			   return;
    		   
    	   }
    	   
       }
       
       /**
        * 返回事件
        */
       $scope.onClose=function(){
    	   $modalInstance.close();
       }
		
		
		
			
	}]);
})();